package cn.bingo.yunsj.utils;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * 普通类调用注解容器类
 */
@Component
public class ApplicationContextUtil implements ApplicationContextAware {

    //获取容器上下文
    private static ApplicationContext applicationContext = null;

    /**
     * 注入applicaton
     */
    @Override
    public void setApplicationContext(ApplicationContext applicationContext){
        if(ApplicationContextUtil.applicationContext==null){
            ApplicationContextUtil.applicationContext = applicationContext;
        }
    }

    //获取applicationContext
    public static ApplicationContext getApplicationContext() {
        return applicationContext;
    }

}
